<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
	<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
<script type="text/javascript" src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
   <link href="${approot}/resource/jquery/validate/jquery.validate.css" rel="stylesheet" type="text/css" />
   <link href="${approot}/resource/jquery/validate/style.css" rel="stylesheet" type="text/css" />
   
     <script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
            	 jQuery("#name").validate({
                     expression: "if (VAL) return true; else return false;",
                     message: "分类名称不能为空"
                 });   
                 jQuery('#dept').validated(function(){
 					//alert("通过验证");
 					do_edit();
 				});
            });
            /* ]]> */
        </script>
        
        <script type="text/javascript">
        function do_edit()
        {   
            var str=$('#dept').serializeObject();
            var jsons = $.toJSON(str);
            edit_dept(jsons);
        }


        function edit_dept(jsons){
 	       $.ajax({
 		   	url:'${approot}/admin/caitype/edit',
 		   	dataType: 'json',
 		   	contentType: 'application/json',
 			data:jsons,
 			type:'post',
 			beforeSend:function(){
 			  // $('#main').disabled='true';
 			},
 			error:function(request){
 				//alert(S);
 			},
 			success:function(data){
 				 if(data.msg=="error")
 	 			   {
 	 	 			   alert('分类名称已经存在,请重新输入');
 	 			   }
 	 			   if(data.msg=="succ")
 	 			   {
 	 				  alert('分类修改成功');
 	 				 parent.frames['tree'].location.reload();
 	 				location.href="${approot}/admin/caitype/right/${fid}";
 	 			   }
 			}
 		   });
 	}
        </script>
   
</head>  
  <body style="background:#E8F5FE; padding:15px 18px;" class="scroll_r">
<div id="right_w"><p>当前位置：系统管理 >>部门修改</p></div>

<form method="post" action="" id="dept">
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" class="tab_l">
    <tr>
      <td><b>请按要求填写：</b></td>
      <td align="right">带<span style="color:#ff0000;">*</span>为必填</td>
    </tr>
  </table>
  <table border="0" cellpadding="0" cellspacing="1" width="92%" align="center" id="add_tab">

  <tr>
   <th width="20%"><span style="color:#ff0000; margin:0;">*</span>分类名称：</th>
   <td width="80%"><input type="text" id=name name="name" value="${caitype.name}"></td>
  </tr>
 
 </table>

  <p id="tab_but">
  <input type="hidden" name="id" value="${caitype.id}">
   <input type="submit" value="提 交">
   <input type="button" value="返回" onclick="history.go(-1)"></p>
</form>
</body>
</html>
